//
//  UIImage+ImageWithColor.m
//  UIImage-ImageWithColor
//
//  Created by Bruno Tortato Furtado on 14/12/13.
//  Copyright (c) 2013 No Zebra Network. All rights reserved.
//

#import "UIImage+ImageWithColor.h"

@implementation UIImage (ImageWithColor)

+ (UIImage *)imageWithColor:(UIColor *)color
{
    CGRect rect = CGRectMake(0, 0, 1, 1);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize )size
{
    CGRect  rect =  CGRectMake ( 0 ,  0 , size. width , size. height );
    UIGraphicsBeginImageContext (rect. size );
    CGContextRef  context =  UIGraphicsGetCurrentContext ();
    CGContextSetFillColorWithColor (context,color. CGColor );
    CGContextFillRect (context, rect);
    UIImage  *img =  UIGraphicsGetImageFromCurrentImageContext ();
    UIGraphicsEndImageContext ();
    return  img;
}
@end